<template>
    <app>
    <div class="headers">
        <div>
            <div><h2 style="color: white;text-align:center;vertical-align:middle;"><img :src="require('@/assets/logo.png')" style="vertical-align:middle;" width="100px" height="100px">南宁铁路局行车公寓乘务员就餐消费信息管理系统 </h2></div>
        </div>
    </div>
        <el-container style="height: 100%; border: 1px solid #eee;border-top-color: #065cf7;width: 99.9%">
            <el-aside width="200px" style="background-color: rgb(238, 241, 246)">
                <el-menu>
                    <el-submenu v-if="sendPermission.userManagement" index="1">
                        <template slot="title">
                            <span>用户管理</span>
                        </template>
                            <el-menu-item v-if="type===0||type===3"  @click="Router('/home/userManagement')">机务</el-menu-item>
                            <el-menu-item v-if="type===1||type===3" @click="Router('/home/apatmentUserManagement')">公寓</el-menu-item>
                    </el-submenu>
                    <el-submenu v-if="sendPermission.permissionManagement" index="3">
                        <template slot="title">
                            <span>权限管理</span>
                        </template>
                            <el-menu-item v-if="type===0||type===3" @click="Router('/home/departmentPermission')">机务</el-menu-item>
                            <el-menu-item v-if="type===1||type===3" @click="Router('/home/apartmentPermission')">公寓</el-menu-item>
                    </el-submenu>
                    <el-submenu v-if="sendPermission.diningManagement" index="2">
                        <template slot="title">
                            <span>餐别管理</span>
                        </template>
                            <el-menu-item v-if="type===0||type===3" @click="Router('/home/diningManagement')">机务</el-menu-item>
                            <el-menu-item v-if="type===1||type===3" @click="Router('/home/apartmentDiningManagement')">公寓</el-menu-item>
                    </el-submenu>
                            <el-menu-item v-if="type===5">退款列表</el-menu-item>
                            <el-menu-item v-if="type===5">接口管理</el-menu-item>
                            <el-menu-item v-if="type===5">统计报表</el-menu-item>
                            <el-menu-item v-if="type===1||type===3" @click="Router('/home/apatment')">公寓科管理</el-menu-item>
                            <el-menu-item v-if="type===5">日志</el-menu-item>
                            <el-menu-item v-if="type===3" @click="Router('/home/informationManagement')">公告管理</el-menu-item>
                            <el-menu-item v-if="type===3" @click="Router('/home/discussManagement')">评论管理</el-menu-item>
                            <el-menu-item v-if="type===3" @click="Router('/home/updateHomeImage')">APP轮播图修改</el-menu-item>
                            <el-menu-item v-if="type===3" @click="Router('/home/adminStatements')">财务报表</el-menu-item>
                            <el-menu-item @click="logout">退出</el-menu-item>
                </el-menu>
                <el-container>
                </el-container>
            </el-aside>

            <router-view />
        </el-container>

    </app>
</template>

<script>
    export default {
        name: "home",
        data(){
            return{
                type:99,
                sendPermission:{
                    diningManagement:false,
                    userManagement:false,
                    permissionManagement:false,
                    subsidy:false,
                },
            }
        },
        methods:{
            Router(link){
                this.$router.push({path:link})
            },
            init(){
                this.$api.getUserInfo()
                    .then(res=>{
                        localStorage.setItem('userId',res.data.userId);
                        localStorage.setItem('userUsername',res.data.userUsername);
                        localStorage.setItem('userJobNumber',res.data.userJobNumber);
                        localStorage.setItem('userName',res.data.userName);
                        localStorage.setItem('userIdCard',res.data.userIdCard);
                        localStorage.setItem('userSubsidyStatus',res.data.userSubsidyStatus);
                        localStorage.setItem('userInfo',res.data.userInfo);
                        localStorage.setItem('userSex',res.data.userSex);
                        localStorage.setItem('userUserStatus',res.data.userUserStatus);
                        localStorage.setItem('departmentId',res.data.departmentId);
                        localStorage.setItem('departmentName',res.data.departmentName);
                        this.$store.state.DepartmentsType=res.data.type;
                        this.type=res.data.type;
                        this.$api.getRoleInfo(res.data.userId)
                        .then(res=>{
                            this.sendPermission=res.data;
                        });
                    });
            },
            logout(){
                this.$api.logout()
                    .then(res=>{
                        if(res.code==200){
                            localStorage.clear();
                            this.Router('/')
                            this.$message.success('注销成功')
                        }else {
                            this.$message.error(res.message)
                        }
                    })

            }
        },
        mounted() {
            this.init()
        }
    }
</script>

<style scoped>
.headers{
    width: 99.9%;
    height: 100px;
    background-color: #065cf7;
    /*text-align:center;*/
    /*line-height:100px;*/
}
.el-header {
    background-color: #B3C0D1;
    color: #333;
    line-height: 60px;
}

.el-aside {
    color: #333;
}

</style>
